#include "UiLanguageDownBar.h"
#ifdef MERGER_APP_TO_SHELL
	extern HINSTANCE g_SDHResModuleHandle;
#endif
UiLanguageDownBar::UiLanguageDownBar()
{
}

UiLanguageDownBar::~UiLanguageDownBar()
{
}

BOOL UiLanguageDownBar::InitUiWin(void)
{
	BOOL bRtn = FALSE;
//	SetWindowLong(m_hWnd, GWL_USERDATA, (LONG) this);
	LoadiInterItem();
	InitImages();
	return bRtn;
}

void UiLanguageDownBar::PaintWin(HDC hdc, RECT* prcWin, RECT* prcUpdate)
{
	m_DownBarBG->Draw(hdc, prcWin, false, false);
}

int UiLanguageDownBar::OnLButtonDown(UINT fwKeys, int xPos, int yPos)
{
	return UiWin::OnLButtonDown(fwKeys, xPos, yPos);

}

int UiLanguageDownBar::OnLButtonUp(UINT fwKeys, int xPos, int yPos)
{
	return UiWin::OnLButtonUp(fwKeys, xPos, yPos);

}

void UiLanguageDownBar::LoadiInterItem()
{
//jdhuang 20120818
#ifndef MERGER_APP_TO_SHELL
	m_DownBarBG = ImagingHelper::GetImageObject(MzGetInstanceHandle(), 1063);
#else
	m_DownBarBG = ImagingHelper::GetImageObject(g_SDHResModuleHandle, 8000);
#endif
	RECT rtBtnCountry[] = {
		6, 5, 128, 155,
		139, 5, 261, 155,
		272, 5, 394, 155,
		405, 5, 527, 155,
		538, 5, 660, 155,
		671, 5, 793, 155,
	};
	m_BtnDownBar[LANGUAGE_DOWNBAR_ENGLISH].SetPos(rtBtnCountry[LANGUAGE_DOWNBAR_ENGLISH].left, rtBtnCountry[LANGUAGE_DOWNBAR_ENGLISH].top,
					rtBtnCountry[LANGUAGE_DOWNBAR_ENGLISH].right-rtBtnCountry[LANGUAGE_DOWNBAR_ENGLISH].left,
					rtBtnCountry[LANGUAGE_DOWNBAR_ENGLISH].bottom-rtBtnCountry[LANGUAGE_DOWNBAR_ENGLISH].top);
	m_BtnDownBar[LANGUAGE_DOWNBAR_ENGLISH].SetID(7200);
#ifndef MERGER_APP_TO_SHELL
	m_BtnDownBar[LANGUAGE_DOWNBAR_ENGLISH].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1059, true));
	m_BtnDownBar[LANGUAGE_DOWNBAR_ENGLISH].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1060, true));
#else
	m_BtnDownBar[LANGUAGE_DOWNBAR_ENGLISH].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,8001, true));
	m_BtnDownBar[LANGUAGE_DOWNBAR_ENGLISH].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,8001, true));
#endif
	AddChild(&m_BtnDownBar[LANGUAGE_DOWNBAR_ENGLISH]);

	m_BtnDownBar[LANGUAGE_DOWNBAR_CHINESE].SetPos(rtBtnCountry[LANGUAGE_DOWNBAR_CHINESE].left, rtBtnCountry[LANGUAGE_DOWNBAR_CHINESE].top,
					rtBtnCountry[LANGUAGE_DOWNBAR_CHINESE].right-rtBtnCountry[LANGUAGE_DOWNBAR_CHINESE].left,
					rtBtnCountry[LANGUAGE_DOWNBAR_CHINESE].bottom-rtBtnCountry[LANGUAGE_DOWNBAR_CHINESE].top);
	m_BtnDownBar[LANGUAGE_DOWNBAR_CHINESE].SetID(7201);
#ifndef MERGER_APP_TO_SHELL
	m_BtnDownBar[LANGUAGE_DOWNBAR_CHINESE].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1059, true));
	m_BtnDownBar[LANGUAGE_DOWNBAR_CHINESE].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1060, true));
#else
	m_BtnDownBar[LANGUAGE_DOWNBAR_CHINESE].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,8004, true));
	m_BtnDownBar[LANGUAGE_DOWNBAR_CHINESE].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,8004, true));
#endif
	AddChild(&m_BtnDownBar[LANGUAGE_DOWNBAR_CHINESE]);

	m_BtnDownBar[LANGUAGE_DOWNBAR_ARAB].SetPos(rtBtnCountry[LANGUAGE_DOWNBAR_ARAB].left, rtBtnCountry[LANGUAGE_DOWNBAR_ARAB].top,
					rtBtnCountry[LANGUAGE_DOWNBAR_ARAB].right-rtBtnCountry[LANGUAGE_DOWNBAR_ARAB].left,
					rtBtnCountry[LANGUAGE_DOWNBAR_ARAB].bottom-rtBtnCountry[LANGUAGE_DOWNBAR_ARAB].top);
	m_BtnDownBar[LANGUAGE_DOWNBAR_ARAB].SetID(7202);
#ifndef MERGER_APP_TO_SHELL
	m_BtnDownBar[LANGUAGE_DOWNBAR_ARAB].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1059, true));
	m_BtnDownBar[LANGUAGE_DOWNBAR_ARAB].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1060, true));
#else
	m_BtnDownBar[LANGUAGE_DOWNBAR_ARAB].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,8007, true));
	m_BtnDownBar[LANGUAGE_DOWNBAR_ARAB].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,8007, true));
#endif
	AddChild(&m_BtnDownBar[LANGUAGE_DOWNBAR_ARAB]);

	m_BtnDownBar[LANGUAGE_DOWNBAR_RUSSIA].SetPos(rtBtnCountry[LANGUAGE_DOWNBAR_RUSSIA].left, rtBtnCountry[LANGUAGE_DOWNBAR_RUSSIA].top,
					rtBtnCountry[LANGUAGE_DOWNBAR_RUSSIA].right-rtBtnCountry[LANGUAGE_DOWNBAR_RUSSIA].left,
					rtBtnCountry[LANGUAGE_DOWNBAR_RUSSIA].bottom-rtBtnCountry[LANGUAGE_DOWNBAR_RUSSIA].top);
	m_BtnDownBar[LANGUAGE_DOWNBAR_RUSSIA].SetID(7203);
#ifndef MERGER_APP_TO_SHELL
	m_BtnDownBar[LANGUAGE_DOWNBAR_RUSSIA].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1059, true));
	m_BtnDownBar[LANGUAGE_DOWNBAR_RUSSIA].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1060, true));
#else
	m_BtnDownBar[LANGUAGE_DOWNBAR_RUSSIA].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,8010, true));
	m_BtnDownBar[LANGUAGE_DOWNBAR_RUSSIA].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,8010, true));
#endif
	AddChild(&m_BtnDownBar[LANGUAGE_DOWNBAR_RUSSIA]);

	m_BtnDownBar[LANGUAGE_DOWNBAR_PORTUGAL].SetPos(rtBtnCountry[LANGUAGE_DOWNBAR_PORTUGAL].left, rtBtnCountry[LANGUAGE_DOWNBAR_PORTUGAL].top,
					rtBtnCountry[LANGUAGE_DOWNBAR_PORTUGAL].right-rtBtnCountry[LANGUAGE_DOWNBAR_PORTUGAL].left,
					rtBtnCountry[LANGUAGE_DOWNBAR_PORTUGAL].bottom-rtBtnCountry[LANGUAGE_DOWNBAR_PORTUGAL].top);
	m_BtnDownBar[LANGUAGE_DOWNBAR_PORTUGAL].SetID(7204);
#ifndef MERGER_APP_TO_SHELL
	m_BtnDownBar[LANGUAGE_DOWNBAR_PORTUGAL].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1059, true));
	m_BtnDownBar[LANGUAGE_DOWNBAR_PORTUGAL].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1060, true));
#else
	m_BtnDownBar[LANGUAGE_DOWNBAR_PORTUGAL].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,8013, true));
	m_BtnDownBar[LANGUAGE_DOWNBAR_PORTUGAL].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,8013, true));
#endif
	AddChild(&m_BtnDownBar[LANGUAGE_DOWNBAR_PORTUGAL]);

	m_BtnDownBar[LANGUAGE_DOWNBAR_IRAN].SetPos(rtBtnCountry[LANGUAGE_DOWNBAR_IRAN].left, rtBtnCountry[LANGUAGE_DOWNBAR_IRAN].top,
					rtBtnCountry[LANGUAGE_DOWNBAR_IRAN].right-rtBtnCountry[LANGUAGE_DOWNBAR_IRAN].left,
					rtBtnCountry[LANGUAGE_DOWNBAR_IRAN].bottom-rtBtnCountry[LANGUAGE_DOWNBAR_IRAN].top);
	m_BtnDownBar[LANGUAGE_DOWNBAR_IRAN].SetID(7205);
#ifndef MERGER_APP_TO_SHELL
	m_BtnDownBar[LANGUAGE_DOWNBAR_IRAN].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1059, true));
	m_BtnDownBar[LANGUAGE_DOWNBAR_IRAN].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1060, true));
#else
	m_BtnDownBar[LANGUAGE_DOWNBAR_IRAN].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,8016, true));
	m_BtnDownBar[LANGUAGE_DOWNBAR_IRAN].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,8016, true));
#endif
	AddChild(&m_BtnDownBar[LANGUAGE_DOWNBAR_IRAN]);

}

BOOL UiLanguageDownBar::InitImages()
{
/*
	HDC hDC = GetDC(m_hWnd);
//jdhuang

	RECT rcClient = GetClientRect();
//	GetClientRect(m_hWnd, &rcClient);

	m_hBakDC = CreateCompatibleDC(hDC);

	m_hBitmapBakDC = CreateCompatibleBitmap(hDC, RECT_WIDTH(rcClient), RECT_HEIGHT(rcClient));
	SelectObject(m_hBakDC, m_hBitmapBakDC);

	//jdhuang 20090616
//	HDC hMemDc = CreateCompatibleDC(m_hBakDC);

	if(m_DownBarBG)
	{
		m_DownBarBG->Draw(m_hBakDC, &rcClient, false, false);
//		DeleteDC(hMemDc);
	}
	ReleaseDC(m_hWnd, hDC);
*/
	return TRUE;
}
void UiLanguageDownBar::DeleteImages()
{
	m_DownBarBG->UnloadImage();
}